package com.demo.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户信息表 Mapper 接口
 * @author ZM
 * @since 2020-11-23
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 通过用户ID，获取用户（只返回名称）
     * @param uid   用户ID
     * @return
     */
    String getUnameById(@Param("uid")Integer uid);

    /**
     * 通过角色ID，查询是否存在用户使用
     * @param roleId
     * @return
     */
    User getUserByRoleId(@Param("roleId")Integer roleId);

    /**
     * 通过用户ID，获取用户（工号）
     * @param uid   用户ID
     * @return
     */
    User getWorkId(@Param("uid") Integer uid);

    /**
     * 通过登录名称获取
     * @param loginName
     * @return
     */
    User getLoginName(@Param("loginName")String loginName);

    /**
     * 通过工号获取
     * @param workSn
     * @return
     */
    User getWork(@Param("workSn")String workSn);

    User getUserByPass(@Param("userId")Integer userId,@Param("userPass")String userPass);

    List<String> queryRemindUserWordSnList(@Param("userWorkSnList") List<String> userWorkSnList, @Param("workStatusList") Integer[] workStatusList);

    @Select("select * from pd_user where role_id=#{roleId}")
    List<User> queryUserByRole(@Param("roleId") Integer roleId);

    @Select("select * from pd_user where user_type=#{userType}")
    List<User> queryUserByUserType(@Param("userType") int userType);

    @Select("select * from pd_user")
    List<User> queryUserAll();
}
